<template>
  <a-modal title='订单票折' v-model='visible' v-if='visible' width='600px' height='400px' @cancel='this.visible = false' @ok='handleSubmit'>
    <f-form ref='discountForm' :action='api.hyOrderDetailsReturn.discount' v-if='visible' :form-key='this.formItem.orderDetailsReturnId'>
      <f-form-item label='票折金额' type='number' data-type='number' :max='maxAmount' name='saleAmount' :value='formItem.saleAmount' />
    </f-form>
  </a-modal>
</template>
<script>
import api from "../../../js/api"

export default {
  name: "DiscountModal",
  props: {},
  data() {
    return {
      refs: this.$refs,
      api: Object.assign(api, this.api),
      loading: false,
      visible: false,
      formItem: this.getFormItem(),
      maxAmount: 0,
      queryParam: {},
      fileIds: []
    }
  },
  watch: {},
  methods: {
    getFormItem() {
      return {
        orderDetailsReturnId: "",
        saleAmount: 0
      }
    },
    open(record) {
      if (record) {
        this.formItem = record
        this.maxAmount = record.saleAmount
      }
      this.visible = true
    },
    /**
     * 票折提交
     */
    handleSubmit() {
      let params = {
        orderDetailsReturnId: this.formItem.orderDetailsReturnId
      }
      this.$refs["discountForm"].submit(params, () => {
        this.$emit("success")
        this.visible = false
      })
    }
  },
  created() {
  },
  components: {}
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
